<template>
  <!-- 输入框 -->
  <header class="header">
    <h1>小黑记事本</h1>
    <input v-model="TodoName" @keyup.enter="handleAdd" placeholder="请输入任务" class="new-todo" />
    <button @click="handleAdd" class="add">添加任务</button>
  </header>
</template>

<script>
export default {
  data() {
    return {
      TodoName: ""
    };
  },
  methods: {
    handleAdd() {
      if (this.TodoName.trim() === "") return;
      this.$emit("add", this.TodoName);
      this.TodoName = "";
    }
  }
};
</script>

<style>
</style>